//
//  QXEmoticonAttachment.swift
//  图文混排
//
//  Created by QinXin on 15/7/7.
//  Copyright © 2015年 labi3285_Lab. All rights reserved.
//

import UIKit

class QXEmoticonAttachment: NSTextAttachment {
    var chs: String?
    
    /// 返回富文本内容
    class func emoticonString(emoticon: QXEmoticon, font: UIFont) -> NSAttributedString {
        let attachment = QXEmoticonAttachment()
        attachment.chs = emoticon.chs
        attachment.image = UIImage(contentsOfFile: emoticon.imagePath!)
        attachment.bounds = CGRect(x: 0, y: -4, width: font.lineHeight, height: font.lineHeight)
        
        
        let attr = NSAttributedString(attachment: attachment)
        let mAttr = NSMutableAttributedString(attributedString: attr)
        mAttr.addAttribute("NSFontAttributeName", value: font, range: NSMakeRange(0, 1))
        
        return mAttr
    }
}
